package com.qidian.permission.controller;

import com.qidian.permission.entity.User;
import com.qidian.permission.service.UserService;
import com.qidian.permission.util.PerResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 32郗建狄
 * @Company GX631
 * Time 2023/10/18 18:18
 * Description
 */
@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping("/selectById")
    public PerResult selectById(Long userId){
        return userService.selectById(userId);
    }
    @PostMapping("/addUser")
    public PerResult addUser(@RequestBody User user){
        return userService.addUser(user);
    }
    @RequestMapping("/list")
    public PerResult list(User user, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit){
        return userService.selectByPage(user,page,limit);
    }
    @PutMapping("/update")
    public PerResult update(@RequestBody User user){
        return userService.update(user);
    }
    @DeleteMapping("/delete")
    public PerResult delete(Long userId){
        return userService.deleteByUserId(userId);
    }
    @DeleteMapping("/deletes")
    public PerResult deletes(Long[] userId){
        return userService.deletesByUserId(userId);
    }
}
